/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.sales.generics.client.components;

import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;

/**
 *
 * @author v
 */
public class HAccordion extends Composite {

    private final HTMLPanel widget = new HTMLPanel("");

    public HAccordion() {
        initWidget(widget);
        widget.getElement().setId("accordion");
    }

    @Override
    public Widget asWidget() {
        return widget.asWidget();
    }

    public void addContent(Widget header, Widget widget) {
        this.widget.getElement().appendChild(header.getElement());
        this.widget.getElement().appendChild(widget.getElement());
    }

    @Override
    protected void onAttach() {
        super.onAttach();
        createAccordion();
    }

    private native void createAccordion()/*-{   
     $wnd.$(function() {
     $wnd.$( "#accordion" ).accordion({
     collapsible: true,
     heightStyle: "content"
     });
     });
     }-*/;

}
